package com.butang.pojo;

import com.butang.Mapper.UserMapper;
import com.butang.utils.Conversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName: mysqlDateConversion
 * Package: com.butang.pojo
 * Description:
 *
 * @Author BuTang
 * @Create 2023/7/6 19:20
 * @Version 1.0
 */
@Service
public class mysqlDateConversion {
    @Autowired
    private UserMapper userMapper;

    @Transactional
    public void date() {
        List<MetaTagResult> list = userMapper.list();
        List<Analysis> updateList = new ArrayList<>();

        for (MetaTagResult m : list) {
            try {
                Analysis analysis = Conversion.coversion(m);
                updateList.add(analysis);
            } catch (Exception e) {
                // 异常处理逻辑，例如打印日志或进行其他处理
                e.printStackTrace();
                // 如果需要，你可以选择忽略异常并继续循环
                // continue;
            }
        }
        userMapper.batchUpdate(updateList);

    }
}
